<?php
/*
 * Created on Mar 1, 2010
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
?>
<div class="content-inner"><h2>Browse Product</h2>
	<form action="<?=site_url(array("c"=>"cms_product","m"=>"index"))?>" method="post" id="product_search">
	<div class="form-search">
		<table class="" cellpadding="5" cellspacing="0" style="">
			<tbody>
				<tr>
					<td>Keywords </td>
					<td colspan="3"><input type="text" name="keyword" value="<?=$keyword?>" maxlength="50" size="36"/></td>
				</tr>
				<tr>
					<td>From </td>
					<td>
						<input type="text" id="f_rangeStart" name="fromdate" value="<?=$fromdate?>" maxlength="10" size="14"/>
						&nbsp;to&nbsp;
						<input type="text" id="t_rangeStart" name="todate" value="<?=$todate?>" maxlength="10" size="14"/>
					</td>
					<td rowspan="2"><input name="search" type="submit" class="" value="Search" id="search" /></td>
				</tr>
			</tbody>
		</table>
	</div>
</form>
</div>
<br/>
<div class="content-inner">
	<div class="gallery">
		<div class="actions">
		<a href="<?=site_url(array('c' => 'cms_product', 'm' => 'add_product'))?>" title="Add Products">
			<img src="<?=public_base_url()?>admin/images/function/add.gif" width="106" height="31" border="0">
		</a>
		</div>
		<div class="gallery-grid">
			<?php if(!empty($product_list)):$i=0?>
			<?php foreach($product_list as $item):?>
			<div class="item" id="product_<?=$item['id']?>">
				<h5 class="ui-widget-header"><?=$item['keycode']?></h5>
				<a href="<?=$media_thumb['user_media_url'].$item['filename']?>" title="<?=$item['description']?>" class="customGal">
					<img src="<?=$media_thumb['user_media_url'].$item['rawname'].$media_thumb['thumb_marker'].$item["fileext"]?>" alt="<?=$item['title']?>"/>
				</a>
				<p align="center"><a href="<?=site_url(array('c' => 'cms_product', 'm'=>'edit_product', 'id'=>$item['id']))?>" class="modify">Modify</a> <span>&nbsp;&nbsp;|&nbsp;&nbsp;</span> <a href="<?=site_url(array('c' => 'cms_product', 'm'=>'delete_product', 'id'=>$item['id']))?>" class="delete">Delete</a></p>
			</div>
			<?php $i++;endforeach;?>
			<div class="clearfix"></div>
			<?php else:?>
			<h3> There isn't exist item match your requested</h3>
			<?php endif;?>
		</div>
		<div id="pagination"><?=$this->pagination->create_links();?></div>
	</div>
	<div id="dialog-confirm" title="Delete product?" style="display: none;">
		<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>This product will be permanently deleted and cannot be recovered. Are you sure?</p>
	</div>
</div>
<script language="JavaScript" type="text/javascript">
(function($){
	$('a.customGal').zoomimage({
		border: 20,
		centered: true,
		hideSource: true
	});

	$('a.delete').click(function(){
		var href = $(this).attr("href");
		$("#dialog-confirm").dialog({
			resizable: false,
			height:180,
			modal: true,
			buttons: {
				'Delete': function() {
					jQuery.getJSON(href, {},function(data){
						$("#product_"+data.product_id).toggle('slow', function() { $(this).remove();});
					});
					$(this).dialog('close');
				},
				Cancel: function() {
					$(this).dialog('close');
				}
			}
		});
		return false;
	});

	/*$('#pagination a').click(function(){
		var link = $(this).attr('href');
		$("#ui-tabs-2").load(link);
		return false;
	});*/

	$("#f_rangeStart").datepicker({dateFormat: 'yy-mm-dd'});
	$("#t_rangeStart").datepicker({dateFormat: 'yy-mm-dd'});	
})(jQuery);
</script>

